<?php


/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Cmspage
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */
 
 
?>

<?php if ($this->cmspage->owner_id != $this->viewer->getIdentity() && !$this->cmspage->isPublished()): ?>
<div id="global_content">   
    <div class="tip">
      <span>
        <?php echo $this->translate('This page has not been published yet.'); ?>
      </span>
    </div>
  <a onclick="history.go(-1);" href="javascript:void(0);" class="buttonlink icon_back"><?php echo $this->translate('Go Back'); ?></a>
</div>

<?php return; ?>
<?php endif;?>


<?php if ($this->cmspage->owner_id != $this->viewer->getIdentity() && $this->cmspage->maintainance): ?>
<div id="global_content">   
    <div class="tip">
      <span>
        <?php echo $this->translate('This page is offline for maintenance. Please check back soon.'); ?>
      </span>
    </div>
  <a onclick="history.go(-1);" href="javascript:void(0);" class="buttonlink icon_back"><?php echo $this->translate('Go Back'); ?></a>
</div>

<?php return; ?>
<?php endif;?>


<?php if ($this->allowed_script): ?>
  <?php echo $this->headScript()->captureStart(Zend_View_Helper_Placeholder_Container_Abstract::APPEND); ?>
  <?php echo $this->cmspage->header_script; ?>
  <?php echo $this->headScript()->captureEnd(Zend_View_Helper_Placeholder_Container_Abstract::APPEND) ?>
<?php endif; ?>

<?php if ($this->allowed_style): ?>
  <?php $this->headStyle()->appendStyle($this->cmspage->header_style); ?>
<?php endif; ?>

<div class='layout_middle'>
  <div class='cmspage_view'>

  <?php if (!$this->cmspage->isPublished()): ?>
    <div class="tip">
      <span>
        <?php echo $this->translate('No one will be able to view this page until you update its status to Publish.'); ?>
        <?php echo $this->htmlLink(array('route' => 'cmspage_edit', 'cmspage_id' => $this->cmspage->getIdentity()),
          $this->translate("Edit This Page")
        )?>
      </span>
    </div>
  <?php elseif ($this->cmspage->maintainance): ?>
    <div class="tip">
      <span>
        <?php echo $this->translate('This page is in Offline (Maintenance) Mode which prevents site visitors from accessing this page.'); ?>
        <?php echo $this->htmlLink(array('route' => 'cmspage_edit', 'cmspage_id' => $this->cmspage->getIdentity()),
          $this->translate("Turn to Online Mode")
        )?>
      </span>
    </div>
  <?php endif; ?>
  

  <?php if ($this->showtitle): ?>
    <div align="center"><h1>
      <?php echo $this->cmspage->getTitle() ?>
    </h1>
	</div>
  <?php endif; ?>  
  <div><!-- JiaThis Button BEGIN -->
<div id="ckepop">
	<span class="jiathis_txt">分享到：</span>
	<a class="jiathis_button_tools_1"></a>
	<a class="jiathis_button_tools_2"></a>
	<a class="jiathis_button_tools_3"></a>
	<a class="jiathis_button_tools_4"></a>
	<a href="http://www.jiathis.com/share?uid=1514714" class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis" target="_blank">更多</a>
	<a class="jiathis_counter_style"></a>
</div>
<script type="text/javascript">var jiathis_config = {data_track_clickback:true};</script>
<script type="text/javascript" src="http://v2.jiathis.com/code/jia.js?uid=1514714" charset="utf-8"></script>
<!-- JiaThis Button END -->
</div></br>
    <div class="cmspage_view_body">
      <?php echo $this->cmspage->body; ?>
    </div>

  <?php if ($cmspage_field_values = $this->fieldValueLoop($this->cmspage, $this->fieldStructure)): ?>
    <div class="profile_fields cmspage_profile_fields">
      <h4>
        <span><?php echo $this->translate('Page Details');?></span>
      </h4>
      <?php echo $cmspage_field_values; ?>
    </div>
  <?php endif; ?>

  <?php if ($this->showphoto): ?>
    
    <?php $photoCount = $this->paginator->getTotalItemCount(); ?>
    <?php if ($photoCount): ?>
    <div class="cmspage_view_photos">
      <h4><span><?php 
        $album_link = $this->htmlLink(array(
            'route' => 'cmspage_extended',
            'controller' => 'photo',
            'action' => 'list',
            'subject' => $this->cmspage->getGuid(),
          ), $this->translate(array("%s Photo", "%s Photo", $photoCount), $photoCount), array(
        ));
        
        echo $this->translate('Album (%s)', $album_link)?>
        </span>
      </h4>
      
      <ul class="thumbs thumbs_nocaptions">
        <?php foreach( $this->paginator as $photo ): ?>
          <li>
            <a class="thumbs_photo" href="<?php echo $photo->getHref(); ?>">
              <span style="background-image: url(<?php echo $photo->getPhotoUrl('thumb.normal'); ?>);"></span>
            </a>
          </li>
        <?php endforeach;?>
      </ul>
      
    </div>
    <?php endif; ?> 
  <?php endif; ?>

  <?php if ($this->showinfo): ?>
    <div class="cmspage_view_info">
    
      <span class="cmspage_view_author">
        <?php echo $this->translate("Created by %s", $this->htmlLink($this->owner->getHref(), $this->owner->getTitle()));?>
      </span>
      |
      <span class="cmspage_view_date">
        <?php echo $this->translate("Last updated %s", $this->timestamp($this->cmspage->modified_date))?>
      </span>
      |

      <?php if ($this->category):?>
        <span class="cmspage_view_category">
          <?php echo $this->translate('Posted in %s', $this->htmlLink(array('route' => 'cmspage_browse', 'category' => $this->category->category_id), $this->translate($this->category->category_name))); ?>
        </span>
      -   
      <span class="cmspage_view_stat">
        <?php echo $this->translate(array("%s view", "%s views", $this->cmspage->view_count), $this->cmspage->view_count); ?>
      </span>
      <?php endif; ?>
      <?php if (count($this->cmspageTags )):?>
        <span class="cmspage_view_tags">
          <?php foreach ($this->cmspageTags as $tag): ?>
	          <?php if (!empty($tag->getTag()->text)):?>
	            <?php echo $this->htmlLink(array(
	              'route' => 'cmspage_browse',
	              'tag' => $tag->getTag()->tag_id
	            ),
	            '#'.$tag->getTag()->text
	            ); ?>
	          <?php endif; ?>
          <?php endforeach; ?>
        </span>  
      <?php endif; ?>
    </div>
  <?php endif; ?>
  
  <?php if ($this->showtool): ?>
  
      <ul class='cmspage_view_tools'>
        <li>
          <?php echo $this->htmlLink(Array('module'=> 'activity', 'controller' => 'index', 'action' => 'share', 'route' => 'default', 'type' => 'cmspage', 'id' => $this->cmspage->getIdentity(), 'format' => 'smoothbox'), 
            $this->translate("Share"), 
            array('class' => 'smoothbox buttonlink icon_cmspage_share')
          ); ?>
        </li>
        <li>
          <?php echo $this->htmlLink(Array('module'=> 'core', 'controller' => 'report', 'action' => 'create', 'route' => 'default', 'subject' =>  $this->cmspage->getGuid(), 'format' => 'smoothbox'), 
            $this->translate("Report"), 
            array('class' => 'smoothbox buttonlink icon_cmspage_report')
          ); ?>
        </li>
        <?php if ($this->canEdit):?>
        <li>
          <a href='<?php echo $this->url(array('cmspage_id' => $this->cmspage->cmspage_id), 'cmspage_edit', true) ?>' class='buttonlink icon_cmspage_edit'><?php echo $this->translate('Edit Page');?></a>
        </li>
        <?php endif; ?>  
        <?php if( $this->canUpload ): ?>
        <li>
            <?php echo $this->htmlLink(array(
                'route' => 'cmspage_extended',
                'controller' => 'photo',
                'action' => 'upload',
                'subject' => $this->cmspage->getGuid(),
              ), $this->translate('Add Photos'), array(
                'class' => 'buttonlink icon_cmspage_photo_new'
            )) ?>
        </li>
        <?php endif; ?>
        <?php if( $this->canDelete ): ?>
          <li>
            <a href='<?php echo $this->url(array('cmspage_id' => $this->cmspage->cmspage_id), 'cmspage_delete', true) ?>' class='buttonlink icon_cmspage_delete'><?php echo $this->translate('Delete Page');?></a>
          </li>
        <?php endif; ?>
  
      </ul>   
         
  <?php endif; ?>
  
  <?php if ($this->showcomment): ?>
	  <div class="cmspage_view_comments">
	    <?php echo $this->action("list", "comment", "core", array("type"=>"cmspage", "id"=>$this->cmspage->getIdentity())) ?>
	  </div>
  <?php endif; ?>  
  </div>
</div>